﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using System.Collections.Generic;
using Huirui.Cavan.Domain.Seedwork;
using Huirui.Cavan.Domain.MainBoundedContext.StockModule;

namespace Huirui.Cavan.Domain.MainBoundedContext.SalesModule
{
    #region SalesOrder

    /// <summary>
    /// SalesOrder object for NHibernate mapped table 'SalesOrder'.
    /// </summary>
    [Serializable]
    public class SalesOrder : Persistent<string>
    {
        #region Member Variables

        protected DateTime _saleDate;
        protected DateTime _deliveryDate;
        protected string _currency;
        protected decimal _currencyRate;
        protected string _customerOrderCode;
        protected string _deliveryAddress;
        protected SalesIdentifier.CheckType _checkType;
        protected string _remark;
        protected decimal _discountRate;
        protected decimal _discountAmount;
        protected int _receiptType;
        protected int _receiptCondition;
        protected int _payDay;
        protected DateTime _deadDay;
        protected SalesIdentifier.StockOutStatus _stockOutStatus;
        protected SystemIdentifier.CheckedStatus _checkedStatus;
        protected Corporation _corporation;
        protected Customer _customer;
        protected Employee _saleEmployee;
        protected Project _project;
        protected WareHouse _wareHouse;
        protected IList<Sale> _sales;
        protected IList<SalesOrderDetail> _salesOrderDetails;

        #endregion

        #region Constructors

        public SalesOrder() { }

        public SalesOrder(string id, DateTime saleDate, DateTime deliveryDate, string currency, decimal currencyRate, string customerOrderCode, string deliveryAddress,
            SalesIdentifier.CheckType checkType, string remark, decimal discountRate, decimal discountAmount, int receiptType, int receiptCondition, int payDay, DateTime deadDay,
            SalesIdentifier.StockOutStatus stockOutStatus, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation, Customer customer, Employee saleEmployee, WareHouse wareHouse, Project project, SystemIdentifier.CheckedStatus checkedStatus)
        {
            this.Id = id;
            this._saleDate = saleDate;
            this._deliveryDate = deliveryDate;
            this._currency = currency;
            this._currencyRate = currencyRate;
            this._customerOrderCode = customerOrderCode;
            this._deliveryAddress = deliveryAddress;
            this._checkType = checkType;
            this._remark = remark;
            this._discountRate = discountRate;
            this._discountAmount = discountAmount;
            this._receiptType = receiptType;
            this._receiptCondition = receiptCondition;
            this._payDay = payDay;
            this._deadDay = deadDay;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._customer = customer;
            this._saleEmployee = saleEmployee;
            this._project = project;
            this._wareHouse = wareHouse;
            this._stockOutStatus = stockOutStatus;
            this._checkedStatus = checkedStatus;
        }

        #endregion

        #region Public Properties


        public virtual DateTime SaleDate
        {
            get { return _saleDate; }
            set { _saleDate = value; }
        }

        public virtual DateTime DeliveryDate
        {
            get { return _deliveryDate; }
            set { _deliveryDate = value; }
        }

        public virtual string Currency
        {
            get { return _currency; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Currency", value, value.ToString());
                _currency = value;
            }
        }

        public virtual decimal CurrencyRate
        {
            get { return _currencyRate; }
            set { _currencyRate = value; }
        }

        public virtual string CustomerOrderCode
        {
            get { return _customerOrderCode; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for CustomerOrderNumber", value, value.ToString());
                _customerOrderCode = value;
            }
        }

        public virtual string DeliveryAddress
        {
            get { return _deliveryAddress; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress", value, value.ToString());
                _deliveryAddress = value;
            }
        }

        public virtual SalesIdentifier.CheckType CheckType
        {
            get { return _checkType; }
            set { _checkType = value; }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual decimal DiscountRate
        {
            get { return _discountRate; }
            set { _discountRate = value; }
        }

        public virtual decimal DiscountAmount
        {
            get { return _discountAmount; }
            set { _discountAmount = value; }
        }

        public virtual int ReceiptType
        {
            get { return _receiptType; }
            set { _receiptType = value; }
        }

        public virtual int ReceiptCondition
        {
            get { return _receiptCondition; }
            set { _receiptCondition = value; }
        }

        public virtual int PayDay
        {
            get { return _payDay; }
            set { _payDay = value; }
        }

        public virtual DateTime DeadDay
        {
            get { return _deadDay; }
            set { _deadDay = value; }
        }

        public virtual SalesIdentifier.StockOutStatus StockOutStatus
        {
            get { return _stockOutStatus; }
            set { _stockOutStatus = value; }
        }

        public virtual SystemIdentifier.CheckedStatus CheckedStatus
        {
            get { return _checkedStatus; }
            set { _checkedStatus = value; }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Customer Customer
        {
            get { return _customer; }
            set { _customer = value; }
        }

        public virtual Employee SaleEmployee
        {
            get { return _saleEmployee; }
            set { _saleEmployee = value; }
        }

        public virtual Project Project
        {
            get { return _project; }
            set { _project = value; }
        }

        public virtual WareHouse WareHouse
        {
            get { return _wareHouse; }
            set { _wareHouse = value; }
        }

        public virtual IList<Sale> Sales
        {
            get
            {
                if (_sales == null)
                {
                    _sales = new List<Sale>();
                }
                return _sales;
            }
            set { _sales = value; }
        }

        public virtual IList<SalesOrderDetail> SalesOrderDetails
        {
            get
            {
                if (_salesOrderDetails == null)
                {
                    _salesOrderDetails = new List<SalesOrderDetail>();
                }
                return _salesOrderDetails;
            }
            set { _salesOrderDetails = value; }
        }



        #endregion
    }
    #endregion
}